

<template>

  <div >
       <el-button  class="butB_Sel"  @click="printBtn()">打印</el-button>
    <div class="app-container" id="printcons" >
      <div class="" style="width:1100px;
	  height:1600px;
	  margin:auto;padding: 0px 50px;padding-top:50px;
	  color:#CC3333;
	  font-size:20px;
  ">
      <div >
		 <h2 style="text-align: center;margin: 0 5px;">{{type=='1'?'长期医嘱单':'临时医嘱单'}}</h2>
		
												<p style=";width:16%;float: left;">病区:
												<span style="">{{tabeldata.room}}</span>
												</p>
												<p style=";width:16%;    float: left;">床号:
												<span style="">{{tabeldata.name}}</span>
												</p>
                                              <p style=";width:16%;float: left;">姓名:
												<span style="">{{tabeldata.member.name}}</span>
												</p>
												<p style=";width:16%;    float: left;">性别:
												<span style="">{{tabeldata.member.gender==1?'男':
													tabeldata.member.gender==2?'女':'未知'}}</span>
												</p>
												<p style=";width:16%;float: left;">年龄:
												<span style="">{{tabeldata.member.age}}岁</span>
												</p>
												<p style=";width:16%;    float: left;">住院号:
												<span style="">{{tabeldata.ipt_no}}</span>
												</p>
												<table border="1" width='1000' align="center" bordercolor="#CC3333"  cellspacing="0" cellpadding="0">
												   <tr style="height:40px;text-align:center">
												    <td colspan="2">医嘱时间</td>
												    <!-- <td rowspan='2' style="width:50px;height:40px">执行标志</td> -->
												    <td rowspan='2' style="width:400px;height:40px">{{type=='1'?'长期医嘱':'临时医嘱'}}</td>
												   <td rowspan='2'>医师签名</td>

												     <td rowspan='2'>执行时间</td>
												  
													  
													    <td rowspan='2'>执行者签名</td>
												  
												   </tr>
													   <tr style="height:40px;text-align:center">
												    <td style="">日期</td>
												    <td >时间</td>
											
												   </tr>
												    <tr v-for="(item,index) in tabeldata2" :key="index" style="height:40px;text-align:center">
												  <td></td>
												  <td></td>
											
												  <td> {{item.business_name}}</td>
												  <td></td>
												  <td></td>
												  <td></td>
												 
												
												   </tr>
												</table>
								
											</div>	
				
		        </div>
                 </div>
  </div>
</template>
<script>


import { getdictIndex, } from "@/api/register";
export default {
		props:['yizhudata','type'],
  data() {
    return {
  tabeldata:{
	  name:'',
	  room:'',
  },
  sourcelist:[],
   dayin:false
    };
  },
  
  mounted(){
	  this.tabeldata=this.yizhudata.info
	  console.log(this.yizhudata)
			this.tabeldata.room_nameA=this.tabeldata.room_name.split('/')
		this.tabeldata.room=this.tabeldata.room_nameA[1]
		this.tabeldata.name=this.tabeldata.room_nameA[3]
			this.tabeldata2=this.yizhudata.advice
				if (this.tabeldata2.length<28) {
			for (let i = 0; i < 38-this.tabeldata2.length; i++) {
				this.tabeldata2.push({
					advice_doctor: '',
advice_doctor_name: "",
business_name: "",
end_time: "0000-00-00 00:00:00",
start_time: "0000-00-00 00:00:00",
stop_doctor_name: '',
stop_nurse_name: '',
				})
				console.log(i)
			}
		}
  },
   watch: {
 
    yizhudata(n) {
		this.tabeldata=n.info
		this.tabeldata.room_nameA=this.tabeldata.room_name.split('/')
		this.tabeldata.room=this.tabeldata.room_nameA[1]
		this.tabeldata.name=this.tabeldata.room_nameA[3]
		this.tabeldata2=n.advice
		if (this.tabeldata2.length<28) {
			for (let i = 0; i < 38-this.tabeldata2.length; i++) {
				this.tabeldata2.push({
					advice_doctor: '',
advice_doctor_name: "",
business_name: "",
end_time: "0000-00-00 00:00:00",
start_time: "0000-00-00 00:00:00",
stop_doctor_name: '',
stop_nurse_name: '',
				})
				console.log(i)
			}
		}
	}},
  methods: {
	  getindex(){
		  	getdictIndex({group_id:'40'}).then(res=>{
				let data = res.data;
				  data.forEach((item, key) => {
				if(item.id==40){
            
             this.sourcelist=item.items;
            } 
			 })
			  })
	  },
	  getpint(){
		  	       this['_API'].getPrintReport({id:this.id}).then(res=>{
                            if(res.code==200){
                               this.tabeldata=res.data
								this.tabeldata.source=this.mapxing(this.tabeldata.source)
								
							}
                    })
	  },
	 
	    mapxing(num) {
      var art = "";
         this.sourcelist.map(function(value,i,array){
            
            if (value.id == num) {
          art = value.name;
        }
        
       })
	   console.log(art)
        return art;  
    },
        printBtn(e) {
            this.dayin=true
         setTimeout(() => {
      this.dayinfun()
     }, 200);
     
    },
        dayinfun(){
             this.remove_ie_header_and_footer();
      let subOutputRankPrint = document.getElementById("printcons");
      console.log(subOutputRankPrint.innerHTML);
      let newContent = subOutputRankPrint.innerHTML;
      let oldContent = document.body.innerHTML;
      document.body.innerHTML = newContent;
      window.print();
    //   window.location.reload();
	 this.$emit('reload')
      document.body.innerHTML = oldContent;
      return false;
        },
    //去掉页眉和页脚
    remove_ie_header_and_footer() {
      var hkey_path;
      hkey_path =
        "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
      try {
        var RegWsh = new ActiveXObject("WScript.Shell");
        RegWsh.RegWrite(hkey_path + "header", "");
        RegWsh.RegWrite(hkey_path + "footer", "");
      } catch (e) {}
    },

    
    
  },
   
};
</script>
<style media="print">
				@page {
				  size: auto; /* auto is the initial value */
				  margin: 0mm; /* this affects the margin in the printer settings */
				}
				@media print {
				}
				body {
				  -webkit-print-color-adjust: exact;
				}
				   	#printcons>>>td{
						width:150px;
                        height: 40px!important;
				
						/* border: 0.5px solid #000000; */
						padding: 0rem;
						margin: 0rem;
						text-align: center !important;
					}
				</style>
<style lang='scss' scoped>
#printcons>>> tr{
						height: 40px!important;
						padding: 20px 10px;
						margin: 0rem;
						
					}
                    	#printcons>>>td{
						width:150px;
                        height: 40px!important;
						height: 100%;
						/* border: 0.5px solid #000000; */
						padding: 0rem;
						margin: 0rem;
						text-align: center !important;
					}
		


</style>